package com.bbc.yuntun.common.utils.file;

import com.bbc.yuntun.common.utils.StringUtils;

/**
 * 媒体类型工具类
 *
 * @author ruoyi
 */
public class MimeTypeUtils {

    /* png格式的图片文件 */
    public static final String IMAGE_PNG = "image/png";

    /* jpg格式的图片文件 */

    public static final String IMAGE_JPG = "image/jpg";

    /* jpeg格式的图片文件 */

    public static final String IMAGE_JPEG = "image/jpeg";

    /* bmp格式的图片文件 */

    public static final String IMAGE_BMP = "image/bmp";

    /* gif格式的图片文件 */

    public static final String IMAGE_GIF = "image/gif";

    /* 常见的图片格式扩展名 */
    public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" };

    /* 常见的flash格式扩展名 */
    public static final String[] FLASH_EXTENSION = { "swf", "flv" };

    /* 常见的音频格式扩展名 */
    public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
            "asf", "rm", "rmvb" };

    /* 常见的视频格式扩展名 */
    public static final String[] VIDEO_EXTENSION = { "mp4", "avi", "rmvb" };

    /* 系统允许的媒体格式扩展名 */
    public static final String[] DEFAULT_ALLOWED_EXTENSION = {
            // 图片
            "bmp", "gif", "jpg", "jpeg", "png",
            // word excel powerpoint
            "doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
            // 压缩文件
            "rar", "zip", "gz", "bz2",
            // 视频格式
            "mp4", "avi", "rmvb",
            // pdf
            "pdf" };

    /**
     * 获取支持的媒体文件扩展名
     *
     * @param prefix 前缀
     * @return 媒体文件扩展名
     */
    public static String getExtension(String prefix) {
        return switch (prefix) {
            case IMAGE_PNG -> "png";
            case IMAGE_JPG -> "jpg";
            case IMAGE_JPEG -> "jpeg";
            case IMAGE_BMP -> "bmp";
            case IMAGE_GIF -> "gif";
            default -> StringUtils.EMPTY;
        };
    }
}
